<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->


<!DOCTYPE html
  PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="DC.Type" content="topic">
<meta name="DC.Title" content="Pod Configuration in the Production Environment for Application-Consistent Backup (General)">
<meta name="product" content="">
<meta name="DC.Relation" scheme="URI" content="kubernetes_CSI_00062.html">
<meta name="prodname" content="">
<meta name="version" content="">
<meta name="brand" content="30-OceanProtect Appliance 1.5.0-1.6.0 Help Center">
<meta name="DC.Publisher" content="20241029">
<meta name="prodname" content="csbs">
<meta name="documenttype" content="usermanual">
<meta name="DC.Format" content="XHTML">
<meta name="DC.Identifier" content="kubernetes_CSI_00066">
<meta name="DC.Language" content="en-us">
<link rel="stylesheet" type="text/css" href="public_sys-resources/commonltr.css">
<title>Pod Configuration in the Production Environment for Application-Consistent Backup (General)</title>
</head>
<body style="clear:both; padding-left:10px; padding-top:5px; padding-right:5px; padding-bottom:5px"><a name="kubernetes_CSI_00066"></a><a name="kubernetes_CSI_00066"></a>

<h1 class="topictitle1">Pod Configuration in the Production Environment for Application-Consistent Backup (General)</h1>
<div><div class="section"><h4 class="sectiontitle">Procedure</h4><ol><li><span>Log in to any node where the kubectl tool has been configured in the Kubernetes cluster.</span></li><li><span>Add labels and annotations to the pod where the application that requires consistent backup resides.</span><p><ol type="a"><li>When adding labels to pods, you can specify the pod to which the label is added based on the pod name or pod label.<ul><li>Add labels based on the pod name as follows:<pre class="screen">kubectl label pod <strong><em>name</em></strong><em> </em>-n <strong><em>namespace</em></strong> hook.dataprotect.backup.io/switch='on'</pre>
</li><li>Add labels based on the pod label as follows:<pre class="screen">kubectl label pod -l <strong><em>label</em></strong>=<em><strong>value</strong></em> -n <strong><em>namespace</em></strong> hook.dataprotect.backup.io/switch='on'</pre>
</li></ul>
<p><a href="#kubernetes_CSI_00066__table1343195818318">Table 1</a> describes the related parameters.</p>
</li><li>When adding annotations to pods, you can specify the pod to which the annotation is added based on the pod name or label.<ul><li>Add annotations based on the pod name as follows:<pre class="screen">kubectl annotate pod <strong><em>name </em></strong>-n <strong><em>namespace</em></strong> pre.hook.dataprotect.backup.io/command=<strong><em>cmd_value</em></strong><strong>1</strong>
kubectl annotate pod <strong><em>name</em></strong><em> </em>-n <strong><em>namespace</em></strong> pre.hook.dataprotect.backup.io/container=<em><strong>container_name</strong></em>
kubectl annotate pod <strong><em>name</em></strong><em> </em>-n <strong><em>namespace</em></strong> post.hook.dataprotect.backup.io/command=<strong><em>cmd_value</em></strong><strong>2</strong>
kubectl annotate pod <strong><em>name</em></strong><em> </em>-n <strong><em>namespace</em></strong> post.hook.dataprotect.backup.io/container=<em><strong>container_name</strong></em></pre>
</li><li>Add annotations based on the pod label as follows:<pre class="screen">kubectl annotate pod -l <strong><em>label=value </em></strong>-n <strong><em>namespace</em></strong> pre.hook.dataprotect.backup.io/command=<strong><em>cmd_value1</em></strong>
kubectl annotate pod -l <strong><em>label=value</em></strong><em> </em>-n <strong><em>namespace</em></strong> pre.hook.dataprotect.backup.io/container=<em><strong>container_name</strong></em>
kubectl annotate pod -l <strong><em>label=value</em></strong><em> </em>-n <strong><em>namespace</em></strong> post.hook.dataprotect.backup.io/command=<strong><em>cmd_value2</em></strong>
kubectl annotate pod -l <strong><em>label=value</em></strong><em> </em>-n <strong><em>namespace</em></strong> post.hook.dataprotect.backup.io/container=<em><strong>container_name</strong></em></pre>
</li></ul>
<p><a href="#kubernetes_CSI_00066__table1343195818318">Table 1</a> describes the related parameters.</p>

<div class="tablenoborder"><a name="kubernetes_CSI_00066__table1343195818318"></a><a name="table1343195818318"></a><table cellpadding="4" cellspacing="0" summary="" id="kubernetes_CSI_00066__table1343195818318" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Command parameters</caption><colgroup><col style="width:50%"><col style="width:50%"></colgroup><thead align="left"><tr><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.1.2.2.2.1.2.3.2.3.1.1"><p>Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.1.2.2.2.1.2.3.2.3.1.2"><p>Description</p>
</th>
</tr>
</thead>
<tbody><tr><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.1.2.2.2.1.2.3.2.3.1.1 "><p>name</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.1.2.2.2.1.2.3.2.3.1.2 "><p>Name of the pod to be selected.</p>
</td>
</tr>
<tr><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.1.2.2.2.1.2.3.2.3.1.1 "><p>namespace</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.1.2.2.2.1.2.3.2.3.1.2 "><p>Name of the namespace to be selected.</p>
</td>
</tr>
<tr><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.1.2.2.2.1.2.3.2.3.1.1 "><p>label</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.1.2.2.2.1.2.3.2.3.1.2 "><p>Key value of the label of the pod to be selected.</p>
</td>
</tr>
<tr><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.1.2.2.2.1.2.3.2.3.1.1 "><p>value</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.1.2.2.2.1.2.3.2.3.1.2 "><p>Value of the label of the pod to be selected.</p>
</td>
</tr>
<tr><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.1.2.2.2.1.2.3.2.3.1.1 "><p>cmd_value1</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.1.2.2.2.1.2.3.2.3.1.2 "><p><strong>hook</strong> command executed before PVC snapshot creation. The following is an example:</p>
<pre class="screen">pre.hook.dataprotect.backup.io/command='["/bin/bash", "-c", "mysql -uroot -ppassword -e \"flush tables with read lock\""]'</pre>
</td>
</tr>
<tr><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.1.2.2.2.1.2.3.2.3.1.1 "><p>cmd_value2</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.1.2.2.2.1.2.3.2.3.1.2 "><p><strong>hook</strong> command executed after PVC snapshot creation. The following is an example:</p>
<pre class="screen">post.hook.dataprotect.backup.io/command='["/bin/bash", "-c", "mysql -uroot -ppassword -e \"flush tables with read lock\""]'</pre>
</td>
</tr>
<tr><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.1.2.2.2.1.2.3.2.3.1.1 "><p>container_name</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.1.2.2.2.1.2.3.2.3.1.2 "><p>Name of the container where the pre-hook or post-hook command is executed. If the annotation of the row that contains this parameter is not configured, the command will be run for the first container in the pod by default.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="note"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p>If there are multiple commands for the <strong>cmd_value1</strong> or <strong>cmd_value2</strong> parameter (for example, the MySQL command), you can batch write multiple commands into a script file. The parameter values can be simplified by entering the command for executing the script file. For details about execution, see <a href="kubernetes_CSI_00067.html">Pod Configuration in the Production Environment for Application-Consistent Backup (MySQL as the Containerized Application)</a> or <a href="kubernetes_CSI_00068.html">Pod Configuration in the Production Environment for Application-Consistent Backup (openGauss as the Containerized Application)</a>.</p>
</div></div>
</li></ol>
</p></li></ol>
</div>
<p></p>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="kubernetes_CSI_00062.html">FAQs</a></div>
</div>
</div>

<div class="hrcopyright"><hr size="2"></div><div class="hwcopyright">Copyright &copy; Huawei Technologies Co., Ltd.</div></body>
</html>